const mysql = require("mysql")
const config = require("../config/mysql")(process.env)

const con = mysql.createConnection(config)

function exec(sql){
  const promise = new Promise((resolve,reject) => {
    con.query(sql,(err,result) => {
      if(err){
        reject(err)
      }
      resolve(result)
    })
  })
  return promise
}

module.exports = exec